﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>业务管理系统</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <environment names="Development">
        <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
        <link rel="stylesheet" href="~/lib/font-awesome/css/font-awesome.css" />
        <link rel="stylesheet" href="~/css/animate.css" />
        <link rel="stylesheet" href="~/css/style.css" asp-append-version="true" />
    </environment>
    <environment names="Staging,Production">
        <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
        <link rel="stylesheet" href="~/lib/font-awesome/css/font-awesome.min.css" />
        <link rel="stylesheet" href="~/css/animate.css" />
        <link rel="stylesheet" href="~/css/style.css" asp-append-version="true" />
    </environment>


</head>
<body class="gray-bg">

    <div class="middle-box text-center loginscreen  animated fadeInDown">
        <div>
            <div>

                <h1 class="logo-name">Am</h1>

            </div>
            <h3>欢迎进入业务管理系统</h3>
            @*<p>
                    Perfectly designed and precisely prepared admin theme with over 50 pages with extra new web app views.
                </p>*@
            @*<p>Login in. To see it in action.</p>*@
            <form class="m-t" role="form" action="#">
                <div class="form-group">
                    <input type="text" id="loginName" class="form-control" placeholder="用户名…" required="">
                </div>
                <div class="form-group">
                    <input type="password" id="loginPassword" class="form-control" placeholder="密码…" required="">
                </div>
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="验证码…" id="captcha" required="">
                    <img id="CheckCodeImg" src="/Home/Captcha" alt="" onclick="RefreshCheckCode()" style="cursor: pointer;">
                </div>

                <button type="button" class="btn btn-primary block full-width m-b" onclick="DoLogin()">登陆</button>
                <a class="btn btn-sm btn-white btn-block" href="@Url.Action(" Register", "Pages" )">新建账号</a>
                <a href="#"><small>忘记密码?</small></a>
                @*<p class="text-muted text-center"><small>还没有账号?</small></p>*@

            </form>
            <p class="m-t"> <small>Marble 使用Inspinia 框架创建 &copy; 2019</small> </p>
        </div>
    </div>

    <div class="modal fade" id="loading" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop='static'>
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="myModalLabel">提示</h4>
                </div>
                <div class="modal-body" id="loading-body">
                    系统登录中,请稍后...<span id="result"></span>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="dialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop='static'>
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" id="myModalLabel">提示</h4>
                </div>
                <div class="modal-body" id="dialog-body">
                    系统登录中,请稍后...<span id="result"></span>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>                   
                </div>
            </div>
        </div>
    </div>
</body>

<environment names="Development">
    <script src="~/lib/jquery/dist/jquery.js"></script>
    <script src="~/lib/Popper/popper.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
    <script src="~/lib/metisMenu/dist/jquery.metisMenu.js"></script>
    <script src="~/lib/slimScroll/jquery.slimscroll.js"></script>
    <script src="~/lib/pace/pace.js"></script>
    <script src="~/js/script.js" asp-append-version="true"></script>

    <!-- Only for demo purpose -->
    <script src="~/js/skin.config.js"></script>
</environment>
<environment names="Staging,Production">
    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/Popper/popper.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="~/lib/metisMenu/dist/jquery.metisMenu.js"></script>
    <script src="~/lib/pace/pace.min.js"></script>
    <script src="~/lib/slimScroll/jquery.slimscroll.min.js"></script>
    <script src="~/js/script.js" asp-append-version="true"></script>
</environment>
<script type="text/javascript">
    function Clear() {
        $("#loginPassword").val('');
        $("#loginName").val('');
        $("#captcha").val('');
    }

            function DoLogin() {
                if ($("#loginName").val().trim() == '') {
                    $("#dialog-body").html('用户名不能为空');
                    $('#dialog').modal('show');
                    return false;
                }
                if ($("#loginPassword").val().trim() == '') {
                    $("#dialog-body").html('密码不能为空');
                    $('#dialog').modal('show');
                    return false;
                }
                if ($("#captcha").val().trim() == '') {
                    $("#dialog-body").html('验证码不能为空');
                    $('#dialog').modal('show');
                    return false;
                }
               
                $.post("Home/LoginOper", {
                    loginName: $("#loginName").val(),
                    loginPassword: $("#loginPassword").val(),
                    captcha: $("#captcha").val()
                }, function (data) {
                   
                    if (data.result != "OK") {

                        RefreshCheckCode();
                        Clear();
                        $('#dialog-body').html(data.message);
                        $('#dialog').modal('show');
                    } else {
                        window.location.href = data.message;
                    }
                  
                });
                 
                //maskDiv = Ext.getBody().mask("系统登录中,请稍后...", '', 300);
                //App.direct.Login(
                //    App.loginName.getValue(),
                //    App.loginPassword.getValue(),
                //    App.captcha.getValue(), {
                //        success: function (result) {
                //            if (result.Result != "OK") {
                //                Ext.Msg.alert('信息', result.Message);
                //                RefreshCheckCode();
                //                Clear();
                //                Ext.getBody().unmask();
                //            } else {
                //                window.location.href = result.Message;
                //            }
                //        },
                //        failure: function (error) {
                //            Ext.Msg.alert('信息', error);
                //            Ext.getBody().unmask();

                //        }
                //    });
            }

    function RefreshCheckCode() {
        var imgSrc = $("#CheckCodeImg");
        var src = imgSrc.attr("src");
        imgSrc.attr("src", chgUrl(src));
        //时间戳
        //为了使每次生成图片不一致，即不让浏览器读缓存，所以需要加上时间戳
        function chgUrl(url) {
            var timestamp = (new Date()).valueOf();
            urlurl = url.substring(0, 11);
            if ((url.indexOf("?") >= 0)) {
                urlurl = url + "&t=" + timestamp;
            } else {
                urlurl = url + "?t=" + timestamp;
            }
            return urlurl;
        }


    }



    $(function () {
        $(document).keydown(function (e) {
            if (e.keyCode == 13) {
                DoLogin();
            }
        });

        //$.post('/TestBatis/List', {
        //    UserId:"aaaa"
        //}, function () {
        //});
    });
</script>
</html>
